package com.mt.roll.wms.controller;

import com.mt.roll.core.base.BaseController;
import com.mt.roll.core.constants.CommonConstant;
import com.mt.roll.core.params.IdParam;
import com.mt.roll.core.validator.groups.AddGroup;
import com.mt.roll.core.validator.groups.PageGroup;
import com.mt.roll.core.validator.groups.UpdateGroup;
import com.mt.roll.core.vo.IdVo;
import com.mt.roll.core.vo.PageVo;
import com.mt.roll.core.vo.R;
import com.mt.roll.wms.params.GradeInformationParam;
import com.mt.roll.wms.params.GradeInformationQueryParam;
import com.mt.roll.wms.service.GradeInformationService;
import com.mt.roll.wms.vo.GradeInformationVo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.validation.groups.Default;

/**
 * @Author weihongyang
 * @Date 2021/11/1 11:23 上午
 * @Version 1.0
 */
@RestController
@RequestMapping(CommonConstant.API_MODULE_WMS + "grade/information")
@Slf4j
@Api(value = "等级信息", tags = "等级信息", hidden = false)
public class GradeInformationController extends BaseController {

    @Autowired
    private GradeInformationService gradeInformationService;

    @PostMapping(value = "add")
    @ApiOperation(value = "新增")
    private R<IdVo> add(@Validated({AddGroup.class, Default.class}) @RequestBody GradeInformationParam gradeInformationParam) {
        return gradeInformationService.add(gradeInformationParam);
    }

    @PostMapping(value = "update")
    @ApiOperation(value = "更新")
    private R<IdVo> update(@Validated({UpdateGroup.class, Default.class}) @RequestBody GradeInformationParam gradeInformationParam) {
        return gradeInformationService.update(gradeInformationParam);
    }

    @PostMapping(value = "delete")
    @ApiOperation(value = "删除信息")
    private R<IdVo> delete(@Validated @RequestBody IdParam idParam) {
        return gradeInformationService.delete(idParam);
    }

    @PostMapping(value = "page")
    @ApiOperation(value = "获取分页信息")
    private R<PageVo<GradeInformationVo>> page(@Validated({PageGroup.class, Default.class}) @RequestBody GradeInformationQueryParam gradeInformationQueryParam) {
        return gradeInformationService.page(gradeInformationQueryParam);
    }
}
